package com.wjm.databaseframework.sub_sqlite;

import android.os.Environment;

import com.wjm.databaseframework.bean.User;
import com.wjm.databaseframework.db.BaseDaoFactory;

import java.io.File;

public enum PrivateDataBaseEnums {
    database("");
    private String value;

    PrivateDataBaseEnums(String value) {
    }

    public String getValue() {
        UserDao baseDao = BaseDaoFactory.getOurInstance().getBaseDao(UserDao.class, User.class);
        if (null != baseDao) {
            User currentUser = baseDao.getCurrentUser();
            if (null != currentUser) {
//                File esd = Environment.getExternalStorageDirectory();
//                String sqliteDatabasePath = esd.getAbsolutePath()  ;
//                File file = new File(sqliteDatabasePath);
//                if (!file.exists()) {
//                    file.mkdirs();
//                }
                //建议写入SD卡
                File file=new File(Environment.getExternalStorageDirectory(),"update/"+currentUser.getId());
                if(!file.exists())
                {
                    file.mkdirs();
                }
//                return file.getAbsolutePath() + "/" + currentUser.getId() + "_login.db";//当前登录用户的数据库为==>1_login.db
                return file.getAbsolutePath()+"/login.db";
            }
        }
        return value;
    }
}
